#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std; 
const int maxn = 1000005,maxh=1000000000;
long long tree[maxn],n,m;

int main(){
	cin>>n>>m;
	int l=0,r=maxh,mid;
	for(int i=1;i<=n;i++){
		cin>>tree[i];
	}
	sort(tree+1,tree+n+1);
	while(l<r){
		mid=(l+r+1)/2;
		long long s=0;
		for(int i=1;i<=n;i++){
			if(tree[i]>mid)s+=tree[i]-mid;
		}
		if(s<m)r=mid-1;
		else l=mid;
	}
	cout<<l<<endl;
}
